package gmiddleware

import (
	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/cors"
)

// 配置跨域处理器
func Cors() fiber.Handler {
	// 获取默认的跨域配置
	corsDefault := cors.ConfigDefault

	// 自定义跨域配置
	corsDefault.AllowHeaders = "Content-Type,AccessToken,X-CSRF-Token,Authorization,Token,X-Token,X-User-Id"
	corsDefault.AllowCredentials = true
	corsDefault.ExposeHeaders = "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type"
	return cors.New(corsDefault)
}
